#include <iostream>
#include "resolver.h"

using namespace std;

timespec diff(timespec start, timespec end);

int main(int argc, char *argv[])
{

        Resolver p;

        timespec start, end, result;

        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
        p.getInput();
        p.buscarSolucion();
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end);

        result = diff(start, end);

        cout << result.tv_sec * (unsigned long) 1000000000 + result.tv_nsec << endl;
        
        // cout << p;

        return 0;
}

timespec diff(timespec start, timespec end)
{
        timespec temp;
        if((end.tv_nsec - start.tv_nsec) < 0)
        {
                temp.tv_sec = end.tv_sec - start.tv_sec - 1;
                temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
        }
        else
        {
                temp.tv_sec = end.tv_sec - start.tv_sec;
                temp.tv_nsec = end.tv_nsec - start.tv_nsec;
        }
        return temp;
}
